package com.nhy.bloggers.mapper;

import com.nhy.bloggers.entity.Blog;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BlogMapper {
    @Select("select id,title,content,user_id,delete_flag, create_time,update_time from blog where delete_flag = 0 " +
            "order by create_time desc")
    List<Blog> selectAllBlog();

    @Insert("insert into blog (title,content,user_id) values (#{title},#{content},#{userId})")
    int insertBlog(Blog record);

    @Select("select * from blog where id = #{id}")
    Blog selectById(Integer id);

    int updateBlog(Blog blog);
}
